Title: SQL W3S (By-BKK) / 114 Index
Tags: Obsidian_to_Anki

Q: What does the SQL CREATE INDEX statement do?
A: It is used to create indexes in tables

Q: What is the benefit of indexes in SQL tables?
A: Indexes make retrieving data faster

Q: True or False: Indexes are visible to users in the database
A: False

Q: True or False: Updating a table with indexes can take more time than updating a table without indexes
A: True

Q: When should you create indexes on SQL table columns?
A: Only on columns that are frequently searched

Q: What is the syntax to create an index on a table in SQL?
A: CREATE INDEX index_name ON table_name (column1, column2, …);

Q: Do indexes allow duplicate values by default?
A: Yes

Q: How to create a unique index in SQL?
A: CREATE UNIQUE INDEX index_name ON table_name (column1, column2, …);

Q: True or False: Unique indexes do not allow duplicate values
A: True

Q: Does syntax for creating indexes remain the same across all SQL databases?
A: No, syntax can vary by database

Q: How do you create an index on multiple columns?
A: List the column names in the parentheses separated by commas

Q: Example: Create an index named "idx_lastname" on the "LastName" column in "Persons" table
A: CREATE INDEX idx_lastname ON Persons (LastName);

Q: Example: Create an index named "idx_pname" on "LastName" and "FirstName" columns in "Persons" table
A: CREATE INDEX idx_pname ON Persons (LastName, FirstName);

Q: What does the DROP INDEX statement do?
A: It deletes an index from a table

Q: Reverse: Deletes an index from a table
A: What does the DROP INDEX statement do?

Q: How do you drop an index in MS Access?
A: DROP INDEX index_name ON table_name;

Q: How do you drop an index in SQL Server?
A: DROP INDEX table_name.index_name;

Q: How do you drop an index in DB2/Oracle?
A: DROP INDEX index_name;

Q: How do you drop an index in MySQL?
A: ALTER TABLE table_name DROP INDEX index_name;

Q: True or False: Indexes always speed up UPDATE operations in tables
A: False

Q: What should you check when creating indexes in SQL?
A: The correct syntax for your database

Q: Reverse: Used to create indexes on columns that should not have duplicate values
A: What is a UNIQUE INDEX?